﻿<!DOCTYPE>

<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>退库申请单-确认</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <style type="text/css">
        .linkbutton{margin-left:20px;width:85px;}
        table tr td{padding:0px 5px}
    </style>
</head>
<body>
      <div class="panelSection">    
        <div class="easyui-panel " title="查询区域" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
           <form id="searchForm" method="post">
	    	<table>
	    		<tr class="divLabel">
                    <td>发动机号:</td>
                    <td>生产订单号:</td>
	    			<td>退库申请单号:</td>
                    <td>退库申请单状态:</td>
                    <td>提交时间起:</td>
                    <td>提交时间止:</td>
	    		</tr>
	    		<tr>
	    			<td><input class="easyui-textbox" type="text" name="Machine" style="width: 120px; height: 22px"/></td>
                    <td><input class="easyui-textbox" type="text" name="MfgOrdername" style="width: 120px; height: 22px"/></td>
                    <td><input class="easyui-textbox" type="text" name="billname" style="width: 120px; height: 22px"/></td>
	    			<td><input id="STATUS" name="status" style="width: 120px; height: 22px"/></td>
                    <td><input class="easyui-datebox" type="text" name="startdate" style="width: 120px; height: 22px"/></td>
                    <td><input class="easyui-datebox" type="text" name="enddate" style="width: 120px; height: 22px"/></td>
                    <td><a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.searchData()">查询</a></td>
	    			<td><a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.searchReset()">重置</a></td>
                    <td></td>
	    		</tr>
	    	</table>
	    </form> 
        </div>
      </div>
      <div class="panelSection">    
        <div class="easyui-panel " title="退库申请" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
           <table id="StockReturnApplyTable" style="height:500px;width:100%"></table>
           <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                     buttons:[{
                            iconCls:'',
                            text:'Go',
                            id:'pageGo'
                    }]
                ">
                    </div>
        </div>
      </div>
      <div class="panelSection">    
        <div class="easyui-panel " title="按钮区域" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
            <div style="margin:15px 0px">
              <a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.StockReturnApplyBillConfirm()">确认</a>
              <a href="javascript:void(0)" class="easyui-linkbutton linkbutton" onclick="page.StockReturnApplyBillReturn()">退回</a>
            </div>
      </div>
      </div>
      <div id="statusMessage" style="font-size: 14px; height: 40px"></div>
     
</body>
</html>

<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/json2.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script>
/*
创建人：longb
日期：2023-01-06
描述：退库申请单-确认js
*/
var page = {
    pagetotal: 0,
    pageSize: 20,
    pageNumber: 1,
    rootPath: getRootPath(), //网站根路径
    ajaxUrl: getRootPath() + "/Ashx/ZsHandler/ZSStockReturnApplyBillHandler.ashx",
    //初始化页面
    init: function () {
        page.bind();
        customizedEasyuiPagination('pp'); //定制化分页
    },
    //页面事件绑定
    bind: function () {
        $('#STATUS').combobox({
            data:[{id:'1',text:'待确认'},{id:'2',text:'已确认'},{id:'',text:'全部'}],
            valueField:'id',
            textField:'text',
            value:'1'
        });
       
        $('#StockReturnApplyTable').datagrid({
            checkOnSelect: false,
            selectOnCheck: false,
            singleSelect: true,
            rownumbers: true,
            nowrap: false,
            onLoadSuccess: function (data) {
                $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                    total: page.pagetotal,
                    pageSize: page.pageSize,
                    pageNumber: page.pageNumber
                });
                customizedEasyuiPagination('pp'); //定制化分页
            },
            columns: [[
                 { field: 'ZSSTOCKRETURNAPPLYBILLID', width: 120, checkbox: true },
                 { field: 'STOCKRETURNAPPLYBILLNO', title: '退库申请单号', width: 120},
                 { field: 'STOCKRETURNTYPE', title: '退库类型', width: 120,formatter:function(value,row,index){if(value=="0"){return'SCTL|生产退料';}else{return'其他';}}},
                 { field: 'MFGORDERNAME', title: '生产订单号', width: 120},
                 { field: 'MACHINENO', title: '发动机号', width: 120},
                 { field: 'PRODUCTNAME', title: '零件编码', width: 120},
                 { field: 'PRODUCTDESCRIPTION', title: '零件名称', width: 150 },
                 { field: 'PRODUCTBATCHNO', title: '批次号', width: 120 },
		         { field: 'STOCKRETURNNUM', title: '退库数量', width: 130 }, //--
                 { field: 'STOCKRETURNREASON', title: '退库原因', width: 200 },
                 { field: 'STATUS', title: '状态', width: 100,formatter:function(value,row,index){if(value==2){return"已完成";}else if(value==1){return"待确认";}else{return"待提交";}} },
                 { field: 'CREATEDATENAME', title: '创建人', width: 100 },
                 { field: 'CREATEDATE', title: '创建时间', width: 150 },
                 { field: 'SUBMITNAME', title: '提交人', width: 100 },
                 { field: 'SUBMITDATE', title: '提交时间', width: 150 },
                 { field: 'CONFIRMNAME', title: '确认人', width: 100 },
                 { field: 'CONFIRMDATE', title: '确认时间', width: 150 }
	           ]],
        });
        //分页事件
        $('#pp').pagination({
            onSelectPage: function (pageNumber, pageSize) {
                customizedEasyuiPagination('pp'); //定制化分页
                page.pageSize = pageSize; page.pageNumber = pageNumber;
                page.getStockReturnApplyData();
            }
        });
        //绑定分页go按钮
        $('#pageGo').on("click", function () {
            var pageNumber = $(this).parents('tr').find('.pagination-num').val();
            page.pageNumber = pageNumber;
            page.getStockReturnApplyData();
        });
        //清除按钮
        $('#btnReset').on("click", function () {
            page.reset(true, true);
            page.pageNumber = 1; page.pagetotal = 0
            $('#pp').pagination('refresh', {
                total: page.pagetotal,
                pageSize: page.pageSize,
                pageNumber: page.pageNumber
            });
        });
    },
   
    //查询
    searchData: function () {
        page.reset(false, true);
        page.pageNumber = 1;
        page.getStockReturnApplyData();
        $('#EditorForm').form("clear");
    },
    //查询退库申请单信息
    getStockReturnApplyData: function () {
        var frdata = $('#searchForm').serializeArray();
        var data = {};
        $.each(frdata, function () {
            data[this.name] = this.value
        });
        var param = {
            action: "getStockReturnApplyDataByPageSize",
            pageSize: page.pageSize,
            pageNumber: page.pageNumber,
            data: JSON.stringify(data)
        };
        page.post(param, function (res) {
            if (res.Result) {
                page.pagetotal = res.RowCount;
                $('#StockReturnApplyTable').datagrid('loadData', res.DBTable);
            }
        });
    },
    StockReturnApplyBillConfirm:function(){
        page.updateStockReturnBillData('confirm');
    },
    StockReturnApplyBillReturn:function(){
        page.updateStockReturnBillData('return');
    },
    //保存退库申请单信息
    updateStockReturnBillData: function (type) {
        var rows=$('#StockReturnApplyTable').datagrid('getChecked');
        var data=[];
        $.each(rows,function(index,item){
            if(item.STATUS==1){
                data.push(item);
            }
        });
        if(data.length==0){displayMessage("请选择至少一条【待确认】退库申请单信息，再进行操作",false);return;}
         page.post({action:'updateStockReturnBillData',data:JSON.stringify(data),type:type}, function (res) {
            if (res.Result) {
                page.getStockReturnApplyData();
            }
            displayMessage(res.Message, res.Result);
        });
    },
   
    //查询重置
    searchReset: function () {
        $('#searchForm').form('clear');
        page.bind();
    },

    //清除方法，重要！！！
    reset: function (iscondition, isresult) {
        clearMessage();
    },
    //post数据
    post: function ( param, callback) {
        $.ajax({
            type: "Post",
            url: page.ajaxUrl,
            data: param,
            cashe: false,
            async: true,
            dataType: "json",
            beforeSend: function () {
                $.messager.progress({ text: '', msg: '处理中...' });
            },
            success: function (data) {
                $.messager.progress('close');
                callback(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.messager.progress('close');
                displayMessage(XMLHttpRequest.responseText, false);
            }
        });
    }
}
$(function () {
    page.init();
});
</script>

